package j

import (
	"test/lib/jupiter/app"
	"github.com/douyu/jupiter/pkg/server"
	"google.golang.org/grpc"
)

const _ = grpc.SupportPackageIsVersion6

var DefEngine *app.Engine

/*

	cpu检测:
		go tool pprof -top -tree http://localhost:6060/debug/pprof/profile?seconds=60


	内存检测:
		go tool pprof -top -tree http://localhost:6060/debug/pprof/heap


	gomod版本
		google.golang.org/grpc v1.36.0
    	google.golang.org/protobuf v1.25.0

	nacos地址
		acm.aliyun.com
		addr-hz-internal.edas.aliyun.com

*/
func New(cfg app.Config) *app.Engine {
	DefEngine = app.New(cfg)
	return DefEngine
}

//运行服务
func Run(servers ...server.Server) error {
	if DefEngine.Error != nil {
		return DefEngine.Error
	}
	return DefEngine.Run(servers...)
}

//自定义nacos配置读取规则
func SetReadConfigFunc(fn func(string) (app.ServerConfig, error)) {
	app.DefSetCfg = fn
}
